<template>
  <view class="group-list">
    <navbar ref="navbar" :config="config" backColor="#000"></navbar>
    <view class="today" v-if="groupList.length>0">
      <view class="today-item" >
        <view class="today-left" > 今日必拼 </view>
        <!-- <view class="line">
					
				</view>
				<view class="surplus">
					16点场次仅剩
				</view>
				<view class="time">
					<text>00</text>:<text>07</text>:<text>43</text>
				</view> -->
      </view>
    </view>
    <!-- <view class="commodity" > -->
    <swiper
      class="commodity"
      v-if="groupList && groupList.length > 0"
      :indicator-dots="false"
      :autoplay="false"
      @change="imgActiveFun"
    >
      <!-- <view class="commodity-item"> -->
      <swiper-item
        v-for="(item, index) in groupList"
        :key="index"
        @click="
          goProductDetails('/pages/product/goods/puzzleGoods?id=' + item.id)
        "
      >
        <view class="commodity-item u-mr30">
          <image :src="item.cover" mode=""></image>
          <view class="number">
            <text>{{ item.group_people_num}}人团 </text>
			<view style="color:#FF211F">
            <rich-text
              :nodes="$mUtil.priceBigSmall(item.min_price)"
            ></rich-text>
			</view>
          </view>
         <view class="completed" v-if="item.result_sale_num/10000>1">
            已有<text>{{ (item.result_sale_num/10000).toFixed(1)}}万</text> 人拼
          </view>
		  <view class="completed" v-else>
		  	已有<text>{{ item.result_sale_num}}</text> 人拼
		  </view>
        </view>
      </swiper-item>
      <!-- </view> -->
    </swiper>
    <!-- </view> -->
    <!-- <nodata v-else :config="{ top: 1, content: '暂无商品~' }"></nodata> -->
	
	<view v-else class="nodata" v-show="groupList.length==0">
		<image :src="imgUrl+'/timeLimit/nodata.png'" class="nodataImage"></image>
	
	</view>
	
	
	
    <view class="option" v-if="groupList && groupList.length > 0">
      <!-- <view class="option-item active">
				
			</view> -->
      <view
        class="option-item"
        :class="{ active: activeBannerIndex == index }"
        v-for="(item, index) in groupList"
        :key="index"
      >
      </view>
    </view>
    <view class="content">
      <view class="content-top">
        <view class="content-left"> 精选商品 </view>
        <view class="line"> </view>
        <view class="content-right"> 热销优品快来拼购 </view>
      </view>
      <view class="middle" v-if="hotGroupList && hotGroupList.length > 0">
        <view
          class="middle-item"
          v-for="(item, index) in hotGroupList"
          :key="index"
          @click="
            goProductDetails('/pages/product/goods/puzzleGoods?id=' + item.id)
          "
        >
          <view class="image">
            <image :src="item.cover" mode=""></image>
          </view>
          <view class="middle-right">
            <view class="title u-text2">
              {{ item.title }}
            </view>
			<view class="number">
			  <view class="large">
			    <rich-text
			      :nodes="$mUtil.priceBigSmall(item.min_price)"
			    ></rich-text>
			  </view>
			  <view class="small">
			    <rich-text
			      :nodes="$mUtil.priceBigSmall(item.min_sale_price)"
			    ></rich-text>
			  </view>
			</view>
            <view class="large-box">
              <view class="box">
                <view class="three-people">
                  {{ item.group_people_num }}人拼，已拼<text>{{
                    item.result_sale_num
                  }}</text
                  >件
                </view>
              </view>
              <view class="go-group-work"> 去拼团 </view>
            </view>
          </view>
        </view>
        <loadMore v-if="hotGroupList.length > 0" :status="status"></loadMore>
      </view>
      <!-- <nodata v-else :config="{ top: 1, content: '暂无商品~' }"></nodata> -->
	  <view v-else class="nodata" v-show="groupList.length==0">
	  	<image :src="imgUrl+'/timeLimit/nodata.png'" class="nodataImage"></image>
	  
	  </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
		imgUrl: this.$mConfig.staticUrl,
      config: {
		back: true, //false是tolbar页面 是则不写
		title: '拼团',
		color: '#000',
		//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
		backgroundColor: [1, "#F9F9F9"],
		statusBarFontColor: '#1A1A1A',
		backIconColor: "#000",
      },
      groupList: [],

      page: 1,
      hotGroupList: [],
      status: "more",
      activeBannerIndex: 0,
    
       params:{}
    
    };
  },
  onLoad(options) {

if(options.shopid){
  this.params.shop_id=options.shopid
   
}
  },
  onShow() {
    this.getGroup();
    this.getHotGroup();
  },
  onPullDownRefresh() {
    this.page = 1;
    this.hotGroupList = [];
    this.groupList = [];
    this.getGroup();
    this.getHotGroup();
    uni.stopPullDownRefresh();
  },
  onReachBottom() {
    this.page++;
    this.getHotGroup();
  },
  methods: {
    goProductDetails(url) {
      uni.navigateTo({
        url: url,
      });
    },
    imgActiveFun(e) {
      this.activeBannerIndex = e.detail.current;
    },
    getGroup() {
      this.$http
        .get(
          `/groupbuy/activitygoods/will-you-spell`,
          { limit: 12, page: 1 ,...this.params},
          false
        )
        .then((res) => {
          if (res && res.code == 200) {
            this.groupList = res.list;
          }
        });
    },
    getHotGroup() {
   
      this.$http
        .get(
          `/groupbuy/activitygoods/will-you-spell-page`,
          { limit: 10, page: this.page,...this.params },
          false
        )
        .then((res) => {
          if (res && res.code == 200) {
            this.hotGroupList =this.page==1? res.page.list:this.hotGroupList.concat(res.page.list);
            if (res.page.totalPage <= res.page.currPage) {
              this.status = "noMore";
            } else {
              this.status = "more";
            }
          }
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.middle {
  // margin: 0 20rpx 0 0;
  .middle-item {
    display: flex;
    padding: 20rpx;
	margin-bottom: 30rpx;
	background-color: #ffffff;
	border-radius: 40rpx;
    .image {
      image {
        width: 187rpx;
        height: 187rpx;
        border-radius: 18rpx;
      }
    }
    .middle-right {
      margin-left: 30rpx;
	 display: flex;
	 flex-direction: column;
	 justify-content: space-between;
	  
      width: 100%;
      .title {
        font-size: 28rpx;
        font-weight: 400;
        color: #474747;
		padding-left: 5rpx;
      }
	  .number {
	    display: flex;
	    align-items: flex-end;
	    margin-top: 5rpx;
	    .large {
	      font-size: 36rpx;
	      color: #FF211F;
	      font-weight: bold;
	      text {
	        font-size: 36rpx;
	        // color: 700;
	      }
	    }
	    .small {
	      font-size: 30rpx;
	      // font-weight: 500;
	      color: #AAAAAA;
	      text-decoration: line-through;
	      margin-left: 16rpx;
	    }
	  }
      .large-box {
        display: flex;
        align-items: center;
        justify-content: space-between;
		padding-left: 5rpx;
        .box {
          .three-people {
            font-size: 26rpx;
            color: #FF211F;
            font-weight: 400;
            text {
              margin: 0 5rpx;
            }
          }
        }
        .go-group-work {
          color: #ffffff;
          font-size: 28rpx;
          font-weight: 500;
          padding: 12rpx 27rpx;
          background-color:#FF211F;
          border-radius: 32rpx;
        }
      }
    }
  }
}
.content {
  padding: 0 35rpx;
  // background-color: #ffffff;
  overflow: hidden;
  .content-top {
    display: flex;
    align-items: center;
    margin-top: 45rpx;
    margin-bottom: 22rpx;
    .content-left {
      font-size: 36rpx;
      color: #474747;
      font-weight: bold;
    }
    .line {
      width: 1rpx;
      height: 33rpx;
      margin: 0 15rpx;
      background-color: #9e9e9e;
    }
    .content-right {
      font-size: 24rpx;
      color: #474747;
      font-weight: 400;
    }
  }
}
.option {
  // padding: 30rpx 0;
  display: flex;
  justify-content: center;
  background: #FF211F;
  border-top: 4rpx solid #FF211F;
  .option-item {
    background-color: #FF211F;
    margin: 0 8rpx;
    width: 14rpx;
    height: 14rpx;
    border-radius: 20rpx;
  }
  .active {
    background-color: #FF211F;
    width: 35rpx;
    height: 14rpx;
    border-radius: 7rpx;
  }
}

.commodity {
  margin-top: -195rpx;
  padding:0 35rpx 10rpx 35rpx;
  height: 367rpx;
  background: #FF211F;
  border-bottom: 4rpx solid #FF211F;
  
  /deep/ .uni-swiper-slide-frame {
    width: 42% !important;
  }
  .commodity-item {
    // margin-right: 30rpx;
    border-radius: 16rpx;
    background-color: #ffffff;
    padding: 18rpx;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    image {
      width: 232rpx;
      height: 232rpx;
      border-radius: 16rpx;
    }
    .completed {
      font-size: 26rpx;
      margin-top: 2rpx;
      // font-weight: 400;
      color: #474747;
      text {
		margin: 0 5rpx;
        color: #FF211F;
      }
    }
    .number {
      margin-top: 20rpx;
      font-size: 26rpx;
      color: #474747;
      // font-weight: 500;
      display: flex;
      align-items: center;
      .zero {
        margin-left: 20rpx;
        font-size: 26rpx;
        color: #FF211F;
        // font-weight: 500;
      }
      .one {
        color: #FF211F;
        font-size: 36rpx;
        // font-weight: 700;
      }
      .two {
        color: #FF211F;
        font-size: 22rpx;
        // font-weight: 700;
      }
    }
  }
}

.today {
  background-color: #FF211F;
  overflow: hidden;
  height: 300rpx;
  .today-item {
    display: flex;
    align-items: center;
    margin: 35rpx;
    .today-left {
      font-size: 36rpx;
      color: #ffffff;
      // font-weight: 700;
    }
    .line {
      width: 1rpx;
      height: 33rpx;
      background-color: #ffffff;
      margin: 0 15rpx;
    }
    .surplus {
      font-size: 24rpx;
      color: #ffffff;
      font-weight: 400;
      margin-right: 14rpx;
    }
    .time {
      font-size: 24rpx;
      font-weight: 500;
      color: #ffffff;
      text {
        color: #ff0000;
        padding: 0 4rpx;
        background-color: #dccda4;
        border-radius: 4rpx;
        margin: 0 4rpx;
      }
    }
  }
}
.group-list {
  background-color: #f6f6f6;
}
.nodata {
		width: 307rpx;
		height: 307rpx;
		margin: 0 auto;
		margin-top: 100rpx;

		.nodataImage {
			width: 307rpx;
			height: 307rpx;
		}
	}
</style>
